import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommunityForm, CommunityQuery, CommunityVO } from '@/api/system/community/types';

/**
 * 查询小区列表
 * @param query
 * @returns {*}
 */

export const listCommunity = (query?: CommunityQuery): AxiosPromise<CommunityVO[]> => {
  return request({
    url: '/system/community/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小区详细
 * @param communityId
 */
export const getCommunity = (communityId: string | number): AxiosPromise<CommunityVO> => {
  return request({
    url: '/system/community/' + communityId,
    method: 'get'
  });
};

/**
 * 新增小区
 * @param data
 */
export const addCommunity = (data: CommunityForm) => {
  return request({
    url: '/system/community',
    method: 'post',
    data: data
  });
};

/**
 * 修改小区
 * @param data
 */
export const updateCommunity = (data: CommunityForm) => {
  return request({
    url: '/system/community',
    method: 'put',
    data: data
  });
};

/**
 * 删除小区
 * @param communityId
 */
export const delCommunity = (communityId: string | number | Array<string | number>) => {
  return request({
    url: '/system/community/' + communityId,
    method: 'delete'
  });
};
